package gamagora.game.world
{
	import Box2D.Dynamics.Contacts.b2Contact;
	import Box2D.Dynamics.b2ContactListener;
	
	import gamagora.game.entity.OSPhysicEntity;

	public class OSContactListener extends b2ContactListener
	{
		private var _dataA:OSPhysicEntity;
		private var _dataB:OSPhysicEntity;
		
		public function OSContactListener()
		{
		}
		
		public override function BeginContact(contact:b2Contact):void 
		{
			_dataA = contact.GetFixtureA().GetUserData();
			_dataB = contact.GetFixtureB().GetUserData();
			_dataA.onBeginContact(_dataB);
			_dataB.onBeginContact(_dataA);
		}
		
		public override function EndContact(contact:b2Contact):void 
		{
			_dataA = contact.GetFixtureA().GetUserData();
			_dataB = contact.GetFixtureB().GetUserData();
			_dataA.onEndContact(_dataB);
			_dataB.onEndContact(_dataA);
		}
	}
}